package com.guigu.eduservice.controller;

import com.github.pagehelper.PageInfo;
import com.guigu.common.utils.R;
import com.guigu.eduservice.entity.Equipment;
import com.guigu.eduservice.entity.PurchaseDemand;
import com.guigu.eduservice.service.PurchaseDemandService;
import com.guigu.eduservice.vo.EquipmentVo;
import com.guigu.eduservice.vo.PurchaseDemandDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.stereotype.Controller;

import java.util.List;

/**
 * <p>
 * 求购信息表（存储买家发布的二手机械求购需求） 前端控制器
 * </p>
 *
 * @author Xiaosong
 * @since 2025-10-10
 */
@RestController
@RequestMapping("/advertisement")
public class PurchaseDemandController {
    @Autowired
    PurchaseDemandService purchaseDemandService;
    //查询最新四条求购信息
    @GetMapping("selectFour")
    public R selectFour(){
        System.out.println("进入求购信息");
        List<PurchaseDemand> list = purchaseDemandService.getNewPurchaseDemand();
        System.out.println(list);
        return R.ok().data("list",list);
    }
    //前台-查询所有求购
    @PostMapping("/querypurchasePage/{pageNo}/{pageSize}")
    public R querypurchasePage(@PathVariable Integer pageNo,
                                @PathVariable Integer pageSize,
                                @RequestBody PurchaseDemandDto vo) {
        System.out.println("进入求购分页查询面"+ vo+"pageNo"+pageNo+"pageSize"+pageSize);
        PageInfo<PurchaseDemand> list = purchaseDemandService.queryPurchaseDemandPage(pageNo, pageSize, vo);
        System.out.println("接收到的======="+list);
        return R.ok().data("list",list);
    }
}
